home *** CD-ROM | disk | FTP | other *** search
/ Flash MX Savvy / FlashMX Savvy.iso / pc / MAC / Amapi3D / Amapi3DTrial_Edition / MACROS / Helico.tcl next >
Encoding:
Text File  |  1999-12-09  |  2.2 KB  |  175 lines  |  [TEXT/MMCC]

  1. #SPEC -realnameid 0
  2.  
  3.  
  4.  
  5. # messages table
  6.  
  7. #@@%000@@FR@@Faire une helicoide@@
  8.  
  9. #@@%000@@US@@Helicoidal curve@@
  10.  
  11.  
  12.  
  13. # no shape
  14.  
  15. if {[llength [.amapi scene]] == 0} return
  16.  
  17.  
  18.  
  19. # it's not a curve
  20.  
  21. newshape shape [.amapi current]
  22.  
  23. if {[shape -curve] == 0} return
  24.  
  25.  
  26.  
  27. # set closed flag
  28.  
  29. set closed [shape -closed]
  30.  
  31.  
  32.  
  33. # call tool ruler (get origin & offset)
  34.  
  35. set result [ruler -peakAPoint]
  36.  
  37. set orig [.match $result orig -point3d]
  38.  
  39. set offset [.match $result vector -vector]
  40.  
  41.  
  42.  
  43. # user canceled ruler
  44.  
  45. if {$offset == "" || $orig == ""} return
  46.  
  47.  
  48.  
  49. # verify origin belongs to curve
  50.  
  51. set points [shape -points]
  52.  
  53. for {set i 0} {$i < [llength $points]} {incr i} {
  54.  
  55.     if {[vertex dist [lindex $points $i] $orig] < 0.001} break
  56.  
  57. }
  58.  
  59. if {$i == [llength $points]} return
  60.  
  61. set index $i
  62.  
  63.  
  64.  
  65. #calculate new shape
  66.  
  67. newshape result {
  68.  
  69.     # if cloded curve
  70.  
  71.     if {$closed == 1} {
  72.  
  73.         addpoint [lindex $points $index]
  74.  
  75.         set ind [expr {$index + 1}]
  76.  
  77.         set numpts [llength $points]
  78.  
  79.         
  80.  
  81.         for {set i 0} {$i < $numpts} {incr i} {
  82.  
  83.             if {$ind == $numpts} {
  84.  
  85.                 set ind 0
  86.  
  87.             }
  88.  
  89.         
  90.  
  91.             set x [expr {[lindex $offset 0] * ($i + 1) / $numpts}]
  92.  
  93.             set y [expr {[lindex $offset 1] * ($i + 1) / $numpts}]
  94.  
  95.             set z [expr {[lindex $offset 2] * ($i + 1) / $numpts}]
  96.  
  97.             
  98.  
  99.             addpoint [vertex add [list $x $y $z] [lindex $points $ind]]
  100.  
  101.             
  102.  
  103.             incr ind
  104.  
  105.         }
  106.  
  107.     } else {
  108.  
  109.         # first mountain
  110.  
  111.         set ind 0
  112.  
  113.         set numpts $index
  114.  
  115.         for {set i 0} {$i < $numpts} {incr i} {
  116.  
  117.             set x [expr {[lindex $offset 0] * $i / $numpts}]
  118.  
  119.             set y [expr {[lindex $offset 1] * $i / $numpts}]
  120.  
  121.             set z [expr {[lindex $offset 2] * $i / $numpts}]
  122.  
  123.             addpoint [vertex add [list $x $y $z] [lindex $points $ind]]
  124.  
  125.             
  126.  
  127.             incr ind
  128.  
  129.         }
  130.  
  131.         
  132.  
  133.         # second mountain
  134.  
  135.         set ind $index
  136.  
  137.         set numpts [expr {[llength $points] - $index - 1}]
  138.  
  139.         for {set i 0} {$i <= $numpts} {incr i} {
  140.  
  141.             if {$numpts != 0} {
  142.  
  143.                 set x [expr {[lindex $offset 0] * ($numpts - $i) / $numpts}]
  144.  
  145.                 set y [expr {[lindex $offset 1] * ($numpts - $i) / $numpts}]
  146.  
  147.                 set z [expr {[lindex $offset 2] * ($numpts - $i) / $numpts}]
  148.  
  149.             } else {
  150.  
  151.                 set x [lindex $offset 0]
  152.  
  153.                 set y [lindex $offset 1]
  154.  
  155.                 set z [lindex $offset 2]
  156.  
  157.             }
  158.  
  159.             addpoint [vertex add [list $x $y $z] [lindex $points $ind]]
  160.  
  161.             
  162.  
  163.             incr ind
  164.  
  165.         }
  166.  
  167.     }
  168.  
  169. }
  170.  
  171. result -status open
  172.  
  173. result -checkin
  174.  
  175.